<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="referrer" content="never">
    <meta name="renderer" content="webkit">
    <meta
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
            name="viewport">
    <title>弹幕机器人登录</title>
    <link rel="apple-touch-icon-precomposed"
          href="../../img/headlogo.png" th:href="@{/img/favicon.png}">
    <link rel="shortcut icon" href="../../img/headlogo.png"
          th:href="@{/img/favicon.png}">
    <link rel="stylesheet" href="../../css/style.css" th:href="@{/css/style.css}" type="text/css" media="all">
    <link rel="stylesheet" href="../../css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" type="text/css"
          media="all">
    <script type="text/javascript" src="../../js/jquery-3.7.0.min.js" th:src="@{/js/jquery-3.7.0.min.js}"></script>
    <script type="text/javascript" src="../../js/popper.min.js" th:src="@{/js/popper.min.js}"></script>
    <script type="text/javascript" src="../../js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
    <!--jquery.md5.js-->
    <script type="text/javascript" src="../../js/jquery.md5.js" th:src="@{/js/jquery.md5.js}"></script>
    <script type="text/javascript">
        function login(key) {
            //设置时间 5-秒  1000-毫秒  这里设置你自己想要的时间
            // setTimeout(getApi,3*1000);
            $.ajax({
                url: '../manager/logins',
                async: false,
                cache: false,
                type: 'POST',
                data: {
                    key: key
                },
                dataType: 'json',
                success: function (data) {
                    const flag = data.result;

                    if (flag == true) {
                        window.location.replace("/");
                    } else {
                        alert("暗号错误");
                    }
                }
            })
        }

        $(document).on('click', '#manager_login', function () {
            const manager_key = $.md5($("#manager_key").val());
            login(manager_key);
        });
    </script>
</head>

<body>
<div class="app">
    <div
            class="row align-items-center justify-content-center center-wrapper">
        <div class="col-md-6 m-3">
            <div class="card border-second">
                <div class="card-header">
                    <h2>
                        <span>弹幕机器人登录</span>
                        <iframe
                                src="https://ghbtns.com/github-btn.html?user=BanqiJane&amp;repo=Bilibili_Danmuji&amp;type=star&amp;count=true&amp;size=large"
                                frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
                    </h2>
                </div>
                <div class="card-body">
                    <div class="input-group mb-3">
                        <div class="input-group-append">
                            <span class="input-group-text">暗号:</span>
                        </div>
                        <input type="password" id="manager_key" class="form-control"
                               placeholder="你的暗号" min="3"
                        >
                    </div>
                </div>
                <div class="card-footer">
                    <button type="button" class="btn btn-success" id="manager_login">登录</button>
                    <a th:href="@{/}" class="btn btn-link" style="float: right;">返回</a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>